<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<link href="./css/modern.css" rel="stylesheet">
<link href="./css/style-student-group.css" rel="stylesheet" type="text/css">
</head>
	<%
		String courseNumber = (String) request.getAttribute("courseNumber");
		String sectionNumber = (String) request.getAttribute("sectionNumber");
		String firstname = (String) request.getAttribute("firstname");
		String lastname = (String) request.getAttribute("lastname");
		String message = (String) request.getAttribute("message");
	%>
<script>
function validateTextFields()
{

	var cname = document.forms[0]["CogsName"].value;
	var start = document.forms[0]["Starttime"].value;
	var end = document.forms[0]["Endtime"].value;

	if(cname == "")
	{
		alert("Please fill in the COGS name Field!!");
		return false;
	}
	
	else if(start == "")
	{
		alert("Please fill in the Start Field!!");
		return false;
	}
	else if(end == "")
	{
		alert("Please fill in the End Field!!");
		return false;
	}

	return true;
}

</script>
<body>
	<div id="container">
		<div id="header">
			<br>
			<h1 id="main-title">
				<b><font color="000000">EECE Student Group Assessments</b></font>
			</h1>
			<h2>
				Welcome to <%=courseNumber%> Section <%=sectionNumber%>!
				<a href="index.html">
				<p align="right">
					<font size="5">Logout</font>
				</p>
			</a>
			</h2>
		</div>
			<%if(message.equals("Fail")) {%>
				<div class="error(info, warning)-bar" id="messageDialog" align="center"><br>
					<p><b><font color = "black">Please Form Student Groups before adding new COGS sessions</font></b></p>
				</div>
			<%}%>
		<div id="body">
		    <form id=form method="post" action="ProfBackCoursePortalServlet">
             	<a href = "javascript:;" onclick="document.getElementById('form').submit();" class="back-button big page-back">
             		<input type = "hidden" name = "firstname" value = <%=firstname%>>
					<input type = "hidden" name = "lastname" value = <%=lastname%>>	
					<input type = "hidden" name = "courseNumber" value = "<%=courseNumber%>">
					<input type = "hidden" name = "sectionNumber" value = <%=sectionNumber%>>	
             	</a>
            </form>
			<div id="innerBody" class="page-region-content tiles">
			<%if(!message.equals("Fail")) {%>
			<h1>Add A Cognitive Group Session</h1>
			<p>Please fill in all fields.</p>
			<p>COGS Name (must be unique):</p>
			<form name="form1" method="get" action ="ProfAddCOGSServlet" onsubmit = " return validateTextFields()">
			<p>
			    <input type="text" name="CogsName">
			</p>
			<%int i=0;%>
			 <c:forEach items="${divisionList}" var="dList">
			 	<p><b>Group Division <c:out value="${dList}"/></b></p>
				<p>Start Time (must use 24-hour Time format 00:00):</p>
				<p>
			 	 <input type="text" name="Starttime<%=i%>">
				</p>
				<p>End Time (must use 24-hour Time format 00:00):</p>
				<p>
			  	<input type="text" name="Endtime<%=i%>">
				</p>
				<input type = "hidden" name = "division<%=i%>" value = "${dList}">	
				<%i++;%>
			</c:forEach>
				<input type = "hidden" name = "courseNumber" value = "<%=courseNumber%>">
				<input type = "hidden" name = "sectionNumber" value = <%=sectionNumber%>>
				<input type = "hidden" name = "firstname" value = <%=firstname%>>
				<input type = "hidden" name = "lastname" value = <%=lastname%>>		
			  <input type="submit" name="Submit" value="Submit">
		  </form>
			<br>
			<%}%>
			</div>
		</div>
		<div id="footer">
			&copy;UBC Electrical and Computer Engineering. Styled with <a
				href="http://metroui.org.ua">Metro UI CSS</a>
		</div>
	</div>
</body>
</html>